home *** CD-ROM | disk | FTP | other *** search
- package javax.swing;
-
- import java.io.IOException;
- import java.io.ObjectInputStream;
- import java.io.ObjectOutputStream;
- import java.io.Serializable;
- import java.text.ParseException;
- import java.util.HashMap;
- import java.util.Map;
- import javax.accessibility.Accessible;
- import javax.accessibility.AccessibleContext;
- import javax.swing.event.ChangeEvent;
- import javax.swing.event.ChangeListener;
- import javax.swing.plaf.SpinnerUI;
-
- public class JSpinner extends JComponent implements Accessible {
- private static final String uiClassID = "SpinnerUI";
- private static final Action DISABLED_ACTION = new DisabledAction((1)null);
- private transient SpinnerModel model;
- private JComponent editor;
- private ChangeListener modelListener;
- private transient ChangeEvent changeEvent;
- private boolean editorExplicitlySet;
-
- public JSpinner(SpinnerModel var1) {
- this.editorExplicitlySet = false;
- this.model = var1;
- this.editor = this.createEditor(var1);
- this.setOpaque(true);
- this.updateUI();
- }
-
- public JSpinner() {
- this(new SpinnerNumberModel());
- }
-
- public SpinnerUI getUI() {
- return (SpinnerUI)this.ui;
- }
-
- public void setUI(SpinnerUI var1) {
- super.setUI(var1);
- }
-
- public String getUIClassID() {
- return "SpinnerUI";
- }
-
- public void updateUI() {
- this.setUI((SpinnerUI)UIManager.getUI(this));
- this.invalidate();
- }
-
- protected JComponent createEditor(SpinnerModel var1) {
- if (var1 instanceof SpinnerDateModel) {
- return new DateEditor(this);
- } else if (var1 instanceof SpinnerListModel) {
- return new ListEditor(this);
- } else {
- return (JComponent)(var1 instanceof SpinnerNumberModel ? new NumberEditor(this) : new DefaultEditor(this));
- }
- }
-
- public void setModel(SpinnerModel var1) {
- if (var1 == null) {
- throw new IllegalArgumentException("null model");
- } else {
- if (!var1.equals(this.model)) {
- SpinnerModel var2 = this.model;
- this.model = var1;
- if (this.modelListener != null) {
- this.model.addChangeListener(this.modelListener);
- }
-
- this.firePropertyChange("model", var2, var1);
- if (!this.editorExplicitlySet) {
- this.setEditor(this.createEditor(var1));
- this.editorExplicitlySet = false;
- }
-
- this.repaint();
- this.revalidate();
- }
-
- }
- }
-
- public SpinnerModel getModel() {
- return this.model;
- }
-
- public Object getValue() {
- return this.getModel().getValue();
- }
-
- public void setValue(Object var1) {
- this.getModel().setValue(var1);
- }
-
- public Object getNextValue() {
- return this.getModel().getNextValue();
- }
-
- public void addChangeListener(ChangeListener var1) {
- if (this.modelListener == null) {
- this.modelListener = new ModelListener(this, (1)null);
- this.getModel().addChangeListener(this.modelListener);
- }
-
- this.listenerList.add(ChangeListener.class, var1);
- }
-
- public void removeChangeListener(ChangeListener var1) {
- this.listenerList.remove(ChangeListener.class, var1);
- }
-
- public ChangeListener[] getChangeListeners() {
- return (ChangeListener[])this.listenerList.getListeners(ChangeListener.class);
- }
-
- protected void fireStateChanged() {
- Object[] var1 = this.listenerList.getListenerList();
-
- for(int var2 = var1.length - 2; var2 >= 0; var2 -= 2) {
- if (var1[var2] == ChangeListener.class) {
- if (this.changeEvent == null) {
- this.changeEvent = new ChangeEvent(this);
- }
-
- ((ChangeListener)var1[var2 + 1]).stateChanged(this.changeEvent);
- }
- }
-
- }
-
- public Object getPreviousValue() {
- return this.getModel().getPreviousValue();
- }
-
- public void setEditor(JComponent var1) {
- if (var1 == null) {
- throw new IllegalArgumentException("null editor");
- } else {
- if (!var1.equals(this.editor)) {
- JComponent var2 = this.editor;
- this.editor = var1;
- if (var2 instanceof DefaultEditor) {
- ((DefaultEditor)var2).dismiss(this);
- }
-
- this.editorExplicitlySet = true;
- this.firePropertyChange("editor", var2, var1);
- this.revalidate();
- this.repaint();
- }
-
- }
- }
-
- public JComponent getEditor() {
- return this.editor;
- }
-
- public void commitEdit() throws ParseException {
- JComponent var1 = this.getEditor();
- if (var1 instanceof DefaultEditor) {
- ((DefaultEditor)var1).commitEdit();
- }
-
- }
-
- private void writeObject(ObjectOutputStream var1) throws IOException {
- var1.defaultWriteObject();
- HashMap var2 = new HashMap(1);
- SpinnerModel var3 = this.getModel();
- if (var3 instanceof Serializable) {
- var2.put("model", var3);
- }
-
- var1.writeObject(var2);
- if (this.getUIClassID().equals("SpinnerUI")) {
- byte var4 = JComponent.getWriteObjCounter(this);
- --var4;
- JComponent.setWriteObjCounter(this, var4);
- if (var4 == 0 && this.ui != null) {
- this.ui.installUI(this);
- }
- }
-
- }
-
- private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
- var1.defaultReadObject();
- Map var2 = (Map)var1.readObject();
- this.model = (SpinnerModel)var2.get("model");
- }
-
- public AccessibleContext getAccessibleContext() {
- if (this.accessibleContext == null) {
- this.accessibleContext = new AccessibleJSpinner(this);
- }
-
- return this.accessibleContext;
- }
-
- // $FF: synthetic method
- static Action access$200() {
- return DISABLED_ACTION;
- }
-
- // $FF: synthetic method
- static SpinnerModel access$500(JSpinner var0) {
- return var0.model;
- }
-
- // $FF: synthetic method
- static JComponent access$600(JSpinner var0) {
- return var0.editor;
- }
- }
-